package com.tencent.wuyanzu.whattoeat;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

/**
 * Created by zyfgs2012 on 2016/7/24.
 */
public class AnotherChoiceActivity extends Activity {
    Button anotherChoiceButton;
    Button [] tasteButtons = new Button[7];
    boolean [] clicked = new boolean[7];
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.another_choice);
        anotherChoiceButton = (Button)findViewById(R.id.another_choice_button);
        anotherChoiceButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent mainIntent = new Intent(AnotherChoiceActivity.this,SelectActivity.class);
                AnotherChoiceActivity.this.startActivity(mainIntent);
                AnotherChoiceActivity.this.finish();
            }
        });
        tasteButtons[0] = (Button)findViewById(R.id.taste_choice_1);
        tasteButtons[1] = (Button)findViewById(R.id.taste_choice_2);
        tasteButtons[2] = (Button)findViewById(R.id.taste_choice_3);
        tasteButtons[3] = (Button)findViewById(R.id.taste_choice_4);
        tasteButtons[4] = (Button)findViewById(R.id.taste_choice_5);
        tasteButtons[5] = (Button)findViewById(R.id.taste_choice_6);
        tasteButtons[6] = (Button)findViewById(R.id.taste_choice_7);
        for(int i=0;i<tasteButtons.length;i++) {
            final int idx = i;
            tasteButtons[i].setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if(!clicked[idx]) {
                        v.setBackgroundResource(R.drawable.taste_button_shape_on_click);
                        clicked[idx] = true;
                    } else {
                        v.setBackgroundResource(R.drawable.taste_button_shape);
                        clicked[idx] = false;
                    }

                }
            });
        }
    }

    public static class SelectFoodDetail extends AppCompatActivity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_food_detail);
        }
    }
}
